package com.rika.controller;

import com.rika.pojo.ScmUser;
import com.rika.response.LoginResult;
import com.rika.service.ScmUserService;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class LoginController {
    @Resource
    private ScmUserService scmUserService;

    @PostMapping("login")
    public LoginResult login(String account,String password){
        LoginResult result=new LoginResult();
        ScmUser scmUser=scmUserService.selectByAccount(account);
        if(!scmUser.getPassword().equals(password)||scmUser==null){
            result.setCode(401);
            result.setMsg("用户名或密码错误");
        }else{
            result.setCode(200);
            result.setMsg("登录成功");
            result.setData(scmUser);
        }
        return result;
    }
}
